﻿using System;
using System.Linq;

namespace Com.Lancetinc.Evs.Helpers;

public static class StringExt
{
    public static string[] SplitNewLine(this string str, bool removeEmptyLines = false)
    {
        if (string.IsNullOrEmpty(str))
            return Array.Empty<string>();

        var ary = str.Replace("\r", "").Split('\n');
        if (!removeEmptyLines)
            return ary;
        return ary.Where(x => !string.IsNullOrEmpty(x)).ToArray();
    }
}